extends ColorRect

@onready var weaponRoot = $WeaponRoot
@onready var weaponBoundItem = $WeaponRoot/WeaponItem
@onready var equipmentRoot = $EquipmentRoot
@onready var equipmentLocHead = $EquipmentRoot/EquipmentLocHead
@onready var equipmentLocBody = $EquipmentRoot/EquipmentLocBody
@onready var equipmentLocLeg = $EquipmentRoot/EquipmentLocLeg
@onready var equipmentLocHand = $EquipmentRoot/EquipmentLocHand


func _ready():
	pass
	

func initItems():
	if not Inventory.currentSelectedEntityData:
		return
		
	clearItem()
	
	if Inventory.currentSelectedEntityData.weaponsData.size() > 0:
		weaponBoundItem.initItem(Inventory.currentSelectedEntityData.weaponsData[0])

	if Inventory.currentSelectedEntityData.equipmentsDataDict.has(Consts.EQUIPMENT_LOC_HEAD):
		equipmentLocHead.initItem(Inventory.currentSelectedEntityData.equipmentsDataDict[Consts.EQUIPMENT_LOC_HEAD])
	
	if Inventory.currentSelectedEntityData.equipmentsDataDict.has(Consts.EQUIPMENT_LOC_BODY):
		equipmentLocBody.initItem(Inventory.currentSelectedEntityData.equipmentsDataDict[Consts.EQUIPMENT_LOC_BODY])
	
	if Inventory.currentSelectedEntityData.equipmentsDataDict.has(Consts.EQUIPMENT_LOC_LEG):
		equipmentLocLeg.initItem(Inventory.currentSelectedEntityData.equipmentsDataDict[Consts.EQUIPMENT_LOC_LEG])
	
	if Inventory.currentSelectedEntityData.equipmentsDataDict.has(Consts.EQUIPMENT_LOC_HAND):
		equipmentLocHand.initItem(Inventory.currentSelectedEntityData.equipmentsDataDict[Consts.EQUIPMENT_LOC_HAND])
	

func clearItem():
	for index in range(weaponRoot.get_child_count()):
		var childNode = weaponRoot.get_child(index)
		childNode.clearItem()
		
	for index in range(equipmentRoot.get_child_count()):
		var childNode = equipmentRoot.get_child(index)
		childNode.clearItem()
	
		

